﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace IEC
{
    /// <summary>
    /// ModItemUI.xaml 的交互逻辑
    /// </summary>
    public partial class ModItemUI : UserControl
    {
        ModListItem item;
        public ModItemUI(ModListItem item)
        {
            InitializeComponent();
            this.item = item;
            MetaName.Content = item.metaName;
            DirName.Content = item.folderName;
            if(item.metaName == null)
            {
                MetaName.Visibility = Visibility.Collapsed;
            }
            else
            {
                DirName.Visibility = Visibility.Collapsed;
            }
            EnableMod.IsChecked = !item.Disabled;
            if(item.id == null)
            {
                WorkshopBtn.Visibility = Visibility.Hidden;
            }
        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            System.Diagnostics.Process.Start("https://steamcommunity.com/sharedfiles/filedetails/?id=" + item.id);
        }

        private void EnableMod_Checked(object sender, RoutedEventArgs e)
        {
            this.item.Disabled = !(EnableMod.IsChecked ?? true);
        }
    }
}
